﻿<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% Option Explicit %>
<HTML xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8" />
<META NAME="copyright" CONTENT="Copyright 2009-2010 - Martechina Co.Ltd" />
<META NAME="Author" CONTENT="劢格机械(中国)  Www.Martechina.Com" />
<META NAME="Keywords" CONTENT="" />
<META NAME="Description" CONTENT="" />
<TITLE>编辑友情链接</TITLE>
<link href="css.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../inc/Admin.js"></script>
</HEAD>
<!--#include file="../inc/Const.asp" -->
<!--#include file="../inc/ConnSiteData.asp" -->
<!--#include file="CheckAdmin.asp"-->
<%
'cookie 验证
'if Instr(request.cookies("Martech_com")("AdminPurview"),"|119,")=0 then 
'  response.write ("<font color='red')>你不具有该管理模块的操作权限，请返回！</font>")
'  response.end
'end if

'session 验证
if Instr(session("AdminPurview"),"|23,")=0 then 
  response.write ("<font color='red')>你不具有该管理模块的操作权限，请返回！</font>")
  response.end
end if
'========判断是否具有管理权限
%>
<BODY>
<% 
dim Result
Result=request.QueryString("Result")
dim ID,Name,ViewFlag,LinkType,Face,Url,Remark
ID=request.QueryString("ID")
call FriendLinkEdit() 
%>
<table border="0" cellspacing="1" cellpadding="0" height="0" align="center" width="100%" >
  <tr>
  <td>
<table border="0" cellspacing="1" cellpadding="3" bgcolor="#FFFFFF" align="center" width="100%">
  <tr>
    <td height="24" align="center" nowrap  class=classtop><a href="FriendLinkEdit.asp?Result=Add" onClick='changeAdminFlag("添加友情链接")'>添加友情链接</a><font color="#0000FF">&nbsp;|&nbsp;</font><a href="FriendLinkList.asp" onClick='changeAdminFlag("友情链接列表")'>查看友情链接</a><font color="#0000FF">&nbsp;</font></td>
  </tr>
</table>
<br>
<table border="0" cellspacing="1" cellpadding="3" bgcolor="#FFFFFF" align="center" width="100%">
<script language="javascript">
// 参数说明
// s_Type : 文件类型，可用值为"image","flash","media","file"
// s_Link : 文件上传后，用于接收上传文件路径文件名的表单名
// s_Thumbnail : 文件上传后，用于接收上传图片时所产生的缩略图文件的路径文件名的表单名，当未生成缩略图时，返回空值，原图用s_Link参数接收，此参数专用于缩略图
function showUploadDialog(s_Type, s_Link, s_Thumbnail){
	//以下style=coolblue,值可以依据实际需要修改为您的样式名,通过此样式的后台设置来达到控制允许上传文件类型及文件大小
	var arr = showModalDialog("../martech_editor/dialog/i_upload.htm?style=light&type="+s_Type+"&link="+s_Link+"&thumbnail="+s_Thumbnail, window, "dialogWidth:0px;dialogHeight:0px;help:no;scroll:no;status:no");
}
</script>
  <form name="editForm" method="post" action="FriendLinkEdit.asp?Action=SaveEdit&Result=<%=Result%>&ID=<%=ID%>">
  <tr>
 <td height="27" colspan="4" align="center" class="classtop"><strong>修改连接</strong></td>
</tr>
      <tr class=classtd>
        <td   height="20" align="right">站点名称：</td>
        <td  ><input name="Name" type="text" class="textfield" id="Name" style="WIDTH: 240;" value="<%=Name%>">&nbsp;*&nbsp;不少于3个字符</td>
      </tr>
      <tr class=classtd>
        <td   height="20" align="right">发　　布：</td>
        <td  ><input name="ViewFlag" type="checkbox" style='HEIGHT: 13px;WIDTH: 13px;' value="1" <%if ViewFlag then response.write ("checked")%>></td>
      </tr>  
     <tr class=classtd>
        <td   height="20" align="right">链接类型：</td>
        <td  ><input name="LinkType" type="radio" value="1" <%if LinkType=1 then response.write ("checked=checked")%>/>图片&nbsp;<input name="LinkType" type="radio" value="0" <%if LinkType=0 then response.write ("checked=checked")%>/>文字</td>
      </tr>
      <tr class=classtd>
        <td   height="20" align="right">Logo图片：</td>
        <td  ><input name="Face" type="text" class="textfield" id="Face" style="WIDTH: 240; height:25;" value="<%=Face%>">&nbsp;*&nbsp;&nbsp;<input type=button class="button" style="WIDTH: 80;" value="上传图片" onClick="showUploadDialog('image', 'editForm.Face', '')">&nbsp;&nbsp;</td>
      </tr>
     <tr class=classtd>
        <td   height="20" align="right">链接网址：</td>
        <td  ><input name="Url" type="text" class="textfield" id="Url" style="WIDTH: 290;" value="<%=Url%>">
        &nbsp;*&nbsp;&nbsp;格式为：http://Www.Martechina.Com</td>
      </tr>
      <tr class=classtd>
        <td   height="20" align="right" valign="top">备注说明：
        <td  ><textarea name="Remark" rows="6" class="textfield" id="Remark" style="WIDTH: 490;"><%=Remark%></textarea></td>
      </tr>

      <tr class=classtd>
        <td   height="30" align="right">&nbsp;</td>
        <td   valign="bottom"><input name="submitSaveEdit" type="submit" class="button"  id="submitSaveEdit" value="保存" style="WIDTH: 80;" ></td>
      </tr>

  </form>
</table>
</td>
</tr>
</table>
</BODY>
</HTML>
<%
sub FriendLinkEdit()
  dim Action,rsCheckAdd,rs,sql
  Action=request.QueryString("Action")
  if Action="SaveEdit" then '保存编辑管理员信息
    set rs = server.createobject("adodb.recordset")
    if len(trim(request.Form("Name")))<2 then
      response.write ("<script language=javascript> alert('网站名称为必填项目且不少于2个字符！');history.back(-1);</script>")
      response.end
    end if

    if request.Form("LinkType")=1 then
      if trim(request.Form("Face"))="" then
      response.write ("<script language=javascript> alert('您必须填写Logo地址！');history.back(-1);</script>")
      response.end
      end if
    end if
    if len(trim(request.Form("Url")))<6 then
      response.write ("<script language=javascript> alert('链接网址为必填项目且不少于6个字符！');history.back(-1);</script>")
      response.end
    end if
    if Result="Add" then '创建网站管理员
	  sql="select * from Martech_FriendLink"
      rs.open sql,conn,1,3
      rs.addnew
      rs("Name")=trim(Request.Form("Name"))
	  if Request.Form("ViewFlag")=1 then
        rs("ViewFlag")=Request.Form("ViewFlag")
	  else
        rs("ViewFlag")=0
	  end if
      rs("Face")=trim(Request.Form("Face"))
      rs("Url")=trim(Request.Form("Url"))
	  if Request.Form("LinkType")=1 then
        rs("LinkType")=Request.Form("LinkType")
	  else
        rs("LinkType")=0
	  end if	  
	  rs("Remark")=trim(Request.Form("Remark"))
	  rs("AddTime")=now()
	end if  
	if Result="Modify" then '修改网站管理员
      sql="select * from Martech_FriendLink where ID="&ID
      rs.open sql,conn,1,3
      rs("Name")=trim(Request.Form("Name"))
	  if Request.Form("ViewFlag")=1 then
        rs("ViewFlag")=Request.Form("ViewFlag")
	  else
        rs("ViewFlag")=0
	  end if
      rs("Face")=trim(Request.Form("Face"))
	  rs("Sequence")=99
      rs("Url")=trim(Request.Form("Url"))
	  if Request.Form("LinkType")=1 then
        rs("LinkType")=Request.Form("LinkType")
	  else
        rs("LinkType")=0
	  end if	  
	  rs("Remark")=trim(Request.Form("Remark"))
	end if
	rs.update
	rs.close
    set rs=nothing 
    response.write "<script language=javascript> alert('成功编辑友情链接！');changeAdminFlag('友情链接列表');location.replace('FriendLinkList.asp');</script>"
  else '提取信息
	if Result="Modify" then
      set rs = server.createobject("adodb.recordset")
      sql="select * from Martech_FriendLink where ID="& ID
      rs.open sql,conn,1,1
	  Name=rs("Name")
	  ViewFlag=rs("ViewFlag")
	  LinkType=rs("LinkType")
	  Face=rs("Face")
      Url=rs("Url")
      Remark=rs("Remark")
	  rs.close
      set rs=nothing 
	end if
  end if
end sub
%>
